package work1;

class RegularPolygon {
    private int n;
    private double side;
    private double x;
    private double y;


    public RegularPolygon() {
        this.n = 3;
        this.side = 1;
        this.x = 0;
        this.y = 0;
    }

    public RegularPolygon(int n, double side) {
        this.n = n;
        this.side = side;
        this.x = 0;
        this.y = 0;
    }

    public RegularPolygon(int n, double side, double x, double y) {
        this.n = n;
        this.side = side;
        this.x = x;
        this.y = y;
    }

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }

    public double getSide() {
        return side;
    }

    public void setSide(double side) {
        this.side = side;
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getPerimeter() {
        return n * side;
    }

    // 计算面积
    public double getArea() {
        return (n * side * side) / (4 * Math.tan(Math.PI / n));
    }
}

public class work9_9 {
    public static void main(String[] args) {
        RegularPolygon polygon1 = new RegularPolygon();
        RegularPolygon polygon2 = new RegularPolygon(6, 4);
        RegularPolygon polygon3 = new RegularPolygon(10, 4, 5.6, 7.8);
        System.out.println("Perimeter1: " + polygon1.getPerimeter() + ", Area: " + String.format("%.2f", polygon1.getArea()));
        System.out.println("Perimeter2: " + polygon2.getPerimeter() + ", Area: " + String.format("%.2f", polygon2.getArea()));
        System.out.println("Perimeter3: " + polygon3.getPerimeter() + ", Area: " + String.format("%.2f", polygon3.getArea()));
    }
}